/**
 * Author: Zane
 * Email: 873934580@qq.com
 * Date: 2023/5/2
 */

import { ElNotification } from 'element-plus'
export * from '@/utils/setting'
export * from '@/utils/route'

/**
 * 生成唯一ID
 */
export function uniqueId(): string {
    const prefix = Math.random().toString(36).slice(3, 8)
    const content = Number(`${Date.now()}`).toString(36)
    const suffix = Math.random().toString(36).slice(3, 8)

    return `${prefix}-${content}-${suffix}`
}

export const getUseId = (id: string) => {
    return `${getUri()}_pt_${id}`
}

/**
 * 返回当前域名
 */
export const getUri = () => {
    const { host, protocol } = window.location
    let baseUrl = import.meta.env.VITE_BASE_URL
    return baseUrl === '' ? `${protocol}//${host}` : baseUrl
}

export const success = (msg: string) => {
    ElNotification.success({
        message: msg,
        duration: 1500,
    })
}

export const error = (msg: string) => {
    ElNotification.error({
        message: msg,
        duration: 2000,
    })
}
